package jian.hamster.data
{
	import jian.hamster.controller.GameController;
	import jian.hamster.event.GameEvent;

	public class GameData
	{
		
		public static const CONST_TIME_TOTAL:Number = 3000 * 60;
		private var _timePassed:Number=0;
		
		private static var _instance:GameData;
		private var _score:int = 0; 
		
		public static function get instance():GameData
		{
			return !_instance ? (_instance=new GameData()) : _instance;
		}
		
		public function GameData()
		{
			GameController.instance.addEventListener(GameEvent.ENTER_FRAME, onGameEnterFrame);
		}
		
		protected function onGameEnterFrame(event:GameEvent):void
		{
			_timePassed += 40;			
		}
		
		public function get timePassed():Number
		{
			return _timePassed;
		}
		
		public function get score():int
		{
			return _score;
		}
		
		
		
		public function addScore($socreAdd:int):void
		{
			_score += $socreAdd;	
			GameController.instance.dispatchEvent(new GameEvent(GameEvent.SCORE, _score.toString()));
		}
	}
}